/*
 *  quaternion_test.cc
 *  Untitled
 *
 *  Created by Ben Nolan on 2/11/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include "quaternion.h"
#include "errors.h"
#include <iostream>

#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>

namespace W = Wonderland;

BOOST_AUTO_TEST_CASE(Quaternion_New){
	W::Quaternion v(8,1,2,3);
	
	BOOST_CHECK_EQUAL(v.w, 8);
	BOOST_CHECK_EQUAL(v.x, 1);
	BOOST_CHECK_EQUAL(v.y, 2);
	BOOST_CHECK_EQUAL(v.z, 3);
};

BOOST_AUTO_TEST_CASE(Quaternion_NewFromString){
	W::Quaternion v("0.69, -1234,100,78.3332");

	BOOST_CHECK_CLOSE(v.w, 0.69, 1e-6);
	BOOST_CHECK_CLOSE(v.x, -1234.0, 1e-6);
	BOOST_CHECK_CLOSE(v.y, 100.0, 1e-6);
	BOOST_CHECK_CLOSE(v.z, 78.3332, 1e-6);

	BOOST_CHECK_THROW(
		W::Quaternion q2("34f90n34f90n3490"),
		Wonderland::Errors::BadSerialization
	);
}

BOOST_AUTO_TEST_CASE(Quaternion_toString){
	W::Quaternion q("33,-1234,100,78.3332");
	
	BOOST_CHECK_EQUAL("33,-1234,100,78.3332", q.toString());
}

